<extend name="public@base5"/>
<block name="main">
    <div class="wrap">
        <ul class="nav nav-tabs">
            <li class="nav-item">
                <a class="nav-link" href="{:url('User/index')}">{:lang('ADMIN_USER_INDEX')}</a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="{:url('User/add')}">{:lang('ADMIN_USER_ADD')}</a>
            </li>
            <li class="nav-item">
                <a class="nav-link active">{:lang('ADMIN_USER_EDIT')}</a>
            </li>
        </ul>
        <form method="PUT" class="js-ajax-form margin-top-20" action="admin/users/{$id}">
            <div class="row mb-3">
                <label for="input-user_login" class="col-sm-2 col-form-label text-sm-end"><span class="form-required">*</span>{:lang('USERNAME')}</label>
                <div class="col-md-8 col-sm-10">
                    <input type="text" class="form-control" id="input-user_login" name="user_login"
                           value="{$user_login}">
                </div>
            </div>
            <div class="row mb-3">
                <label for="input-user_pass" class="col-sm-2 col-form-label text-sm-end"><span class="form-required">*</span>{:lang('PASSWORD')}</label>
                <div class="col-md-8 col-sm-10">
                    <input type="text" class="form-control" id="input-user_pass" name="user_pass" value=""
                           placeholder="******">
                </div>
            </div>
            <div class="row mb-3">
                <label for="input-user_email" class="col-sm-2 col-form-label text-sm-end"><span class="form-required">*</span>{:lang('EMAIL')}</label>
                <div class="col-md-8 col-sm-10">
                    <input type="text" class="form-control" id="input-user_email" name="user_email"
                           value="{$user_email}">
                </div>
            </div>
            <div class="row mb-3">
                <label for="input-user_email" class="col-sm-2 col-form-label text-sm-end pt-0"><span class="form-required">*</span>{:lang('ROLE')}</label>
                <div class="col-md-8 col-sm-10">
                    <foreach name="roles" item="vo">
                        <div class="form-check form-check-inline">
                            <php>
                                $disabled='';
                                if(cmf_get_current_admin_id() != 1 && $vo['id'] == 1){
                                $disabled='disabled';
                                }
                                $role_id_checked=in_array($vo['id'],$role_ids)?"checked":"";
                            </php>
                            <input class="form-check-input" type="checkbox" name="role_ids[]" id="role_id-checkbox-{$key}" {$disabled} value="{$vo.id}" {$role_id_checked}>
                            <label class="form-check-label" for="role_id-checkbox-{$key}">{$vo.name}</label>
                        </div>
                    </foreach>
                </div>
            </div>
            <div class="row mb-3">
                <div class="offset-md-2 col-sm-10">
                    <input type="hidden" name="id" value="{$id}"/>
                    <button type="submit" class="btn btn-primary js-ajax-submit">
                        <i class="fa fa-save fa-fw"></i> {:lang('SAVE')}
                    </button>
                    <a class="btn btn-secondary" href="javascript:history.back(-1);">{:lang('BACK')}</a>
                </div>
            </div>
        </form>
    </div>
</block>
